package com.itheima.Advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class BaiduService {
    @Pointcut("execution(* com.itheima.service.UserService.getUrl(..))")
    public void pt() {
    }

    //环绕通知
    @Around("BaiduService.pt()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        //获取参数
        Object[] args = pjp.getArgs();
        //处理参数
        for (int i = 0; i < args.length; i++) {
            //参数转为字符串
            String s = args[i].toString();
            //字符串去除前后空格
            String trim = s.trim();
            //赋值给原来数组
            args[i] = trim;
        }
        //调用源方法
        pjp.proceed(args);
        return null;

    }
}
